package com.sky.adapter;

import java.util.ArrayList;

import com.sky.Model.Item;
import com.sky.Model.LocationItem;
import com.sky.Model.SubjectItem;
import com.sky.Model.serviceItem;
import com.sky.heathcare.R;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;


public class SubjectAdapter extends ArrayAdapter<SubjectItem> {
 Context context;
 int layoutResourceId;
 ArrayList<SubjectItem> data = new ArrayList<SubjectItem>();
 
 static class subjectHolder {
	  TextView nameTxt;
	  ImageView image;

	 }

 public SubjectAdapter(Context context, int layoutResourceId,
   ArrayList<SubjectItem> data) {
  super(context, layoutResourceId, data);
  this.layoutResourceId = layoutResourceId;
  this.context = context;
  this.data = data;
 }

 
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
  View row = convertView;
  subjectHolder holder = null;

  if (row == null) {
   LayoutInflater inflater = ((Activity) context).getLayoutInflater();
   row = inflater.inflate(layoutResourceId, parent, false);

   holder = new subjectHolder();
   holder.nameTxt = (TextView) row.findViewById(R.id.subject_name_text);
   holder.image = (ImageView) row.findViewById(R.id.alias_img);
   row.setTag(holder);
  } else {
   holder = (subjectHolder) row.getTag();
  }

  SubjectItem item = data.get(position);
  holder.nameTxt.setText(item.getName());
  //holder.price.setText(item.getPrice());
  return row;

 }

 
}
